﻿using System;
using System.Data;
using System.Collections.Generic;
using HY.Model.oa;
namespace HY.BLL.oa
{
    /// <summary>
    /// review_cha
    /// </summary>
    public partial class charge
    {
        private readonly HY.DAL.oa.charge dal = new HY.DAL.oa.charge();
        public charge()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int sid)
        {
            return dal.Exists(sid);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(HY.Model.oa.charge model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(HY.Model.oa.charge model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int sid)
        {

            return dal.Delete(sid);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string sidlist)
        {
            return dal.DeleteList(sidlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public HY.Model.oa.charge GetModel(int sid)
        {

            return dal.GetModel(sid);
        }

       
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<HY.Model.oa.charge> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<HY.Model.oa.charge> DataTableToList(DataTable dt)
        {
            List<HY.Model.oa.charge> modelList = new List<HY.Model.oa.charge>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                HY.Model.oa.charge model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new HY.Model.oa.charge();
                    if (dt.Rows[n]["sid"] != null && dt.Rows[n]["sid"].ToString() != "")
                    {
                        model.sid = int.Parse(dt.Rows[n]["sid"].ToString());
                    }
                    if (dt.Rows[n]["gbh"] != null && dt.Rows[n]["gbh"].ToString() != "")
                    {
                        model.gbh = dt.Rows[n]["gbh"].ToString();
                    }
                    if (dt.Rows[n]["item"] != null && dt.Rows[n]["item"].ToString() != "")
                    {
                        model.item = dt.Rows[n]["item"].ToString();
                    }
                    if (dt.Rows[n]["dty"] != null && dt.Rows[n]["dty"].ToString() != "")
                    {
                        model.dty = dt.Rows[n]["dty"].ToString();
                    }
                    if (dt.Rows[n]["dtm"] != null && dt.Rows[n]["dtm"].ToString() != "")
                    {
                        model.dtm = dt.Rows[n]["dtm"].ToString();
                    }
                    if (dt.Rows[n]["pbh"] != null && dt.Rows[n]["pbh"].ToString() != "")
                    {
                        model.pbh = dt.Rows[n]["pbh"].ToString();
                    }
                    if (dt.Rows[n]["pname"] != null && dt.Rows[n]["pname"].ToString() != "")
                    {
                        model.pname = dt.Rows[n]["pname"].ToString();
                    }
                    if (dt.Rows[n]["remark"] != null && dt.Rows[n]["remark"].ToString() != "")
                    {
                        model.remark = dt.Rows[n]["remark"].ToString();
                    }
                    if (dt.Rows[n]["dt"] != null && dt.Rows[n]["dt"].ToString() != "")
                    {
                        model.dt = DateTime.Parse(dt.Rows[n]["dt"].ToString());
                    }
                    if (dt.Rows[n]["sday"] != null && dt.Rows[n]["sday"].ToString() != "")
                    {
                        model.sday = DateTime.Parse(dt.Rows[n]["sday"].ToString());
                    }
                    if (dt.Rows[n]["cmoney"] != null && dt.Rows[n]["cmoney"].ToString() != "")
                    {
                        model.cmoney = decimal.Parse(dt.Rows[n]["cmoney"].ToString());
                    }
                    if (dt.Rows[n]["attach"] != null && dt.Rows[n]["attach"].ToString() != "")
                    {
                        model.attach = dt.Rows[n]["attach"].ToString();
                    }
                    if (dt.Rows[n]["chbh"] != null && dt.Rows[n]["chbh"].ToString() != "")
                    {
                        model.chbh = dt.Rows[n]["chbh"].ToString();
                    }
                    if (dt.Rows[n]["chname"] != null && dt.Rows[n]["chname"].ToString() != "")
                    {
                        model.chname = dt.Rows[n]["chname"].ToString();
                    }
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method
    }
}

